package Lee_code;

public class Lee_219 {
    public boolean containsNearbyDuplicate(int[] nums, int k) {
        //使用滑动窗口
        int left=0, right=0;
        while(right< nums.length)
        {
            if(right-left>k)
            {
                left++;
                for(int i=left+1; i<=right; i++)
                {
                    if(nums[i]==nums[left])
                    {
                        return true;
                    }
                }
            }
            right++;
        }
        return  false;
    }
}
